/*
 * @Author: Marte
 * @Date:   2016-11-02 10:41:20
 * @Last Modified by:   Marte
 * @Last Modified time: 2016-11-03 15:43:56
 */

'use strict';

var config = require('../config');
var Promise = require('bluebird');
var oracledb = require('oracledb');
var util = {};

oracledb.outFormat = oracledb.OBJECT; //每一行作为一个对象[{字段名:字段值}]
oracledb.autoCommit = true; //自动提交

oracledb.connection = function() {
    return oracledb.getConnection({
            user: config.oracle.user,
            password: config.oracle.password,
            connectString: config.oracle.connectString
        });
};

oracledb.quoteStrBySqlValue = function(strvalue) {
    var str = strvalue || '';
    return '\'' + str.replace(/\'/g, '\'\'') + '\'';
};

module.exports = oracledb;
